<?php
/**
 * The GotProrole form, used for creation and edition
 * @package ModuleOrganisationCommunication
 * @version 1.0b
 */
?>

<form action="" method ="post" class="form-crud">
<table cellpadding="0" cellspacing="0" border="0" class="form">
	<tr>
		<td class="form-crud-label" colspan="4"><h3 class="subtitle"><?php echo ($_GET['operation'] == 'edit') ? 'Activité professionnelle #'.$gotprorole->gotproroleId : 'Nouvelle activité professionnelle'; ?></h3></td>
	<tr>
	<tr>
		<td class="form-crud-label"><label for=prorole-contact>Contact :</label></td>
		<td class="form-crud-input"><input id="prorole-contact" type="text" name="prorole-contact" value="<?php echo $contact->lastname.' '.$contact->firstname; ?>" /></td>
		<td class="form-crud-label"><label for="prorole-company">Société :</label></td>
		<td class="form-crud-input"><input id="prorole-company" type="text" name="prorole-company" value="<?php echo $company->name; ?>" /></td>
	</tr>
	<tr>
		<td class="form-crud-label"><label for="prorole-role">Rôle :</label></td>
		<td class="form-crud-input">
			<select id="prorole-role" name="prorole-role">
				<?php
				$prorole = new ProRole();
				$proroleList = $prorole->GetList(Array(Array('proroleId', '>', '0')), 'name');
				foreach ($proroleList as $prorole)
					echo '<option value="'.$prorole->proroleId.'"'.(($gotprorole->proroleId == $prorole->proroleId) ? ' selected="selected"' : '').'>'.$prorole->name.'</option>';
				?>
			</select>
		</td>
	</tr>
	<tr>
		<td class="form-crud-label"><label for=prorole-from>De :</label></td>
		<td class="form-crud-input"><input id="prorole-from" type="text" name="prorole-from" value="<?php echo $dateFrom; ?>" /></td>
		<td class="form-crud-label"><label for="prorole-to">À :</label></td>
		<td class="form-crud-input"><input id="prorole-to" type="text" name="prorole-to" value="<?php echo $dateTo; ?>" /></td>
	</tr>
</table>
<br />
<input type="hidden" value="<?php echo $gotprorole->contactId; ?>" name="prorole-contactId" />
<input type="hidden" value="<?php echo $gotprorole->companyId; ?>" name="prorole-companyId" />
<input type="hidden" value="<?php echo $gotprorole->gotproroleId; ?>" name="prorole-proroleId" />
<input type="hidden" value="<?php echo $_GET['operation']; ?>" name="prorole-operation" />
<a href="#" id="form-prorole" class="submit">Sauvegarder</a>

<?php if ($_GET['operation'] != 'add'): ?>
<table cellpadding="0" cellspacing="0" border="0">
	<tr>
		<td class="form-crud-label" colspan="4"><h3 class="subtitle">Documents</h3></td>
	<tr>
	<tr>
		<td class="form-crud-label"></td>
		<td class="form-crud-input">
			<table cellpadding="0" cellspacing="0" border="0" class="documents">
			<?php
			$documentList = $gotprorole->GetDocumentList();
			foreach ($documentList as $document) {
				$res  = '<tr>';
				$res .= '<td class="del"><a href="'.$document->documentId.'" class="delete-doc"><img src="css/img/bin_empty.png" alt="Delete" /></a></td>';
				$res .= '<td><a href="'.$configuration['appdir'].'data/docs/'.$document->documentId.'.'.$document->extension.'" target="_blank" class="file">'.$document->filename.'.'.$document->extension.'</a></td>';
				$res .= '</tr>';
				echo $res;
			}
			?>
			</table>
		</td>
		<td class="form-crud-label"></td>
		<td class="form-crud-input"></td>
	</tr>
	<tr>
		<td class="form-crud-label"><label for="prorole-file-upload">Ajouter des fichiers :</label></td>
		<td class="form-crud-input"><input id="prorole-file-upload" name="prorole-file-upload" type="file" /></td>
		<td class="form-crud-label"></td>
		<td class="form-crud-input"></td>
	</tr>
	<tr>
		<td class="form-crud-label"></td>
		<td class="form-crud-input"><a href="javascript:$('#prorole-file-upload').uploadifyUpload()" class="upload">Upload</a></td>
		<td class="form-crud-label"></td>
		<td class="form-crud-input"></td>
	</tr>
</table>
<?php endif; ?>

</form>

<div id="result"></div>

<div id="select_contact" class="hidden"></div>
<div id="select_company" class="hidden"></div>